var t = require;
var e = module;
var o = exports;
(o.__esModule = !0), (o.default = void 0);
var n,
    i = (n = t("lt-config")) && n.__esModule ? n : {default: n};
function s(t) {
    return Object.prototype.toString(t).slice(8, -1).toLowerCase();
}
var r = {};
(o.default = r),
    window.wx
        ? (r.init = function () {
              console.log("start to load lt sdk...");
              var t,
                  e = "1.0.0",
                  o = i.default,
                  n = "",
                  r = {},
                  c = "",
                  a = "",
                  u = 0,
                  l = "",
                  d = Date.now(),
                  p = 0,
                  h = "",
                  f = "",
                  g = "",
                  y = !0,
                  m = (function () {
                      var t = "";
                      try {
                          (t = wx.getStorageSync("h_stat_uuid")), wx.setStorageSync("h_ifo", !0);
                      } catch (A) {
                          t = "uuid_getstoragesync";
                      }
                      if (t) n = !1;
                      else {
                          (t = w()), (n = !0);
                          try {
                              wx.setStorageSync("h_stat_uuid", t);
                          } catch (t) {
                              wx.setStorageSync("h_stat_uuid", "uuid_getstoragesync");
                          }
                      }
                      return t;
                  })(),
                  v = "https://sdkapi.xmqixiang.cn/api/",
                  _ = wx.getLaunchOptionsSync(),
                  S = "",
                  b =
                      (Date.now(),
                      Math.floor(1e7 * Math.random()),
                      Date.now(),
                      Math.floor(1e7 * Math.random()),
                      [
                          "h_SendEvent",
                          "h_OnShareAppMessage",
                          "h_ShareAppMessage",
                          "h_SendSession",
                          "h_SendOpenid",
                          "h_GetAdv",
                          "h_ClickAd",
                          "h_ToMinProgram",
                          "h_GetAdvList",
                          "h_GetAdvListPlat",
                          "h_GetAppFlowAdList",
                          ,
                          "h_JudgeRegion"
                      ]);
              function A() {
                  return new Promise(function (t) {
                      wx.login({
                          success: function success(e) {
                              (g = e.code), t("");
                          }
                      });
                  });
              }
              function w() {
                  function t() {
                      return Math.floor(65536 * (1 + Math.random()))
                          .toString(16)
                          .substring(1);
                  }
                  return t() + t() + t() + t() + t() + t() + t() + t();
              }
              function I(t) {
                  return !!t && "array" === Object.prototype.toString.call(t).toLowerCase().slice(8, -1);
              }
              function T(t, e) {
                  var o = wx.getStorageSync("h_event_info");
                  o ? (I(o[e]) ? o[e].push(t) : (o[e] = [t])) : ((o = {})[e] = [t]),
                      wx.setStorageSync("h_event_info", o);
              }
              function N() {
                  var t = wx.getStorageSync("h_event_info");
                  if (t)
                      for (var e in t) {
                          if (t.hasOwnProperty(e)) {
                              var o = t[e];
                              if (I(o))
                                  for (; o.length > 0; ) {
                                      var n = o.pop();
                                      A().then(function () {
                                          k(n, e, !0, !0);
                                      });
                                  }
                          }
                      }
                  wx.setStorageSync("h_event_info", t);
              }
              function k(s, r, d, p) {
                  function h() {
                      return new Promise(function (e) {
                          var o = wx.getStorageSync("tjxx");
                          if (void 0 !== o.openid)
                              for (d in o) {
                                  s[d] = o[d];
                              }
                          "" == s.cd
                              ? e("")
                              : (l++,
                                wx.request({
                                    url: v + "ad/report",
                                    data: s,
                                    header: {se: c || "", op: a || "", img: f || "", au: i.default.company},
                                    method: "POST",
                                    success: function success(n) {
                                        if (
                                            (wx.setStorageSync("tjxx", n.data),
                                            clearTimeout(t),
                                            void 0 !== n.data.rtime && parseInt(n.data.rtime) > 0
                                                ? ((t = setTimeout(function () {
                                                      k(s, e, 2);
                                                  }, 1e3 * parseInt(n.data.rtime))),
                                                  console.log(n.data.rtime))
                                                : void 0 !== o.rtime &&
                                                  parseInt(o.rtime) > 0 &&
                                                  (t = setTimeout(function () {
                                                      k(s, e, 2);
                                                  }, 1e3 * parseInt(o.rtime))),
                                            n.data.Status && 200 == n.data.Status)
                                        ) {
                                            if (n.data.Result.op && "" != n.data.Result.op) {
                                                var i = JSON.parse(JSON.stringify(n)).data.Result.op;
                                                a = i;
                                            }
                                        } else (1 != S && 2 != S) || console.error(n.data.Msg);
                                    },
                                    fail: function fail() {
                                        void 0 !== o.rtime &&
                                            parseInt(o.rtime) > 0 &&
                                            (clearTimeout(t),
                                            (t = setTimeout(function () {
                                                k(s, e, 2);
                                            }, 1e3 * parseInt(o.rtime)))),
                                            T(s, s.ev);
                                    }
                                }));
                      });
                  }
                  (s.cd = g),
                      (s.rq_c = l),
                      (s.ifo = n),
                      (s.ak = o.app_key),
                      (s.uu = m),
                      (s.v = e),
                      (s.st = Date.now()),
                      (s.ev = r),
                      (s.wsr = wx.getLaunchOptionsSync()),
                      (s.ufo = B(s.ufo)),
                      (s.ec = u),
                      p || N(),
                      void 0 === d ? wx.Queue.push(h) : h();
              }
              function B(t) {
                  if (void 0 === t || "" === t) return "";
                  var e = {};
                  for (var o in t) {
                      "rawData" != o && "errMsg" != o && (e[o] = t[o]);
                  }
                  return e;
              }
              function C(t) {
                  var e = {};
                  for (var o in t) {
                      e[o] = t[o];
                  }
                  return e;
              }
              function O(t) {
                  for (var e = "", o = 0; o < t.length; o++) {
                      t[o].length > e.length && (e = t[o]);
                  }
                  return e;
              }
              "" === o.app_key && console.error("请在配置文件(lt-config.js)中填写您的app_key"),
                  (o.app_key = o.app_key.replace(/\s/g, "")),
                  (wx.Queue = new (function () {
                      var t = this;
                      (this.concurrency = 200),
                          (this.queue = []),
                          (this.tasks = []),
                          (this.activeCount = 0),
                          (this.push = function (e) {
                              this.tasks.push(
                                  new Promise(function (o) {
                                      var n = function n() {
                                          t.activeCount++,
                                              e()
                                                  .then(function (t) {
                                                      o(t);
                                                  })
                                                  .then(function () {
                                                      t.next();
                                                  });
                                      };
                                      t.activeCount < t.concurrency ? n() : t.queue.push(n);
                                  })
                              );
                          }),
                          (this.all = function () {
                              return Promise.all(this.tasks);
                          }),
                          (this.next = function () {
                              t.activeCount--, t.queue.length > 0 && t.queue.shift()();
                          });
                  })()),
                  wx.Queue.all(),
                  Promise.all([
                      A(),
                      new Promise(function (t) {
                          wx.getNetworkType({
                              success: function success(e) {
                                  t(e);
                              },
                              fail: function fail() {
                                  t("");
                              }
                          });
                      }),
                      new Promise(function (t) {
                          o.getLocation
                              ? wx.getLocation({
                                    success: function success(e) {
                                        t(e);
                                    },
                                    fail: function fail() {
                                        t("");
                                    }
                                })
                              : wx.getSetting({
                                    success: function success(e) {
                                        e.authSetting["scope.userLocation"]
                                            ? (wx.getLocation({
                                                  success: function success(e) {
                                                      t(e);
                                                  },
                                                  fail: function fail() {
                                                      t("");
                                                  }
                                              }),
                                              t(""))
                                            : t("");
                                    },
                                    fail: function fail() {
                                        t("");
                                    }
                                });
                      })
                  ]).then(function (t) {
                      "" !== t[2]
                          ? ((r.lat = t[2].latitude || ""), (r.lng = t[2].longitude || ""), (r.spd = t[2].speed || ""))
                          : ((r.lat = ""), (r.lng = ""), (r.spd = "")),
                          "" !== t[1] ? (r.nt = t[1].networkType || "") : (r.nt = "");
                      var e = C(r);
                      "" !== t[0] && ((e.ufo = t[0]), (h = t[0])), k(e, "init");
                  }),
                  wx.onShow(function (t) {
                      (l = 0),
                          (_ = t),
                          (p = Date.now()),
                          y || (Date.now(), Math.floor(1e7 * Math.random()), (n = !1), wx.setStorageSync("h_ifo", !1)),
                          (y = !1);
                      var e = C(r),
                          o = C(r);
                      (e.sm = p - d),
                          t.query && t.query.h_share_src && t.shareTicket && "1044" === t.scene
                              ? ((o.tp = "h_share_click"),
                                new Promise(function (t) {
                                    "1044" == _.scene
                                        ? wx.getShareInfo({
                                              shareTicket: _.shareTicket,
                                              success: function success(e) {
                                                  t(e);
                                              },
                                              fail: function fail() {
                                                  t("");
                                              }
                                          })
                                        : t("");
                                }).then(function (t) {
                                    (o.ct = t), k(o, "event");
                                }))
                              : t.query &&
                                t.query.h_share_src &&
                                ((o.tp = "h_share_click"), (o.ct = "1"), k(o, "event")),
                          k(e, "show");
                  }),
                  wx.onHide(function () {
                      var t = C(r);
                      (t.dr = Date.now() - p),
                          "" === h
                              ? wx.getSetting({
                                    success: function success(e) {
                                        e.authSetting["scope.userInfo"]
                                            ? wx.getUserInfo({
                                                  success: function success(e) {
                                                      (t.ufo = e),
                                                          (h = e),
                                                          (f = O(e.userInfo.avatarUrl.split("/"))),
                                                          k(t, "hide");
                                                  }
                                              })
                                            : k(t, "hide");
                                    }
                                })
                              : k(t, "hide");
                  }),
                  wx.onError(function (t) {
                      var e = C(r);
                      (e.tp = "h_error_message"), (e.ct = t), u++, k(e, "event");
                  });
              for (
                  var x = {
                          h_SendEvent: function h_SendEvent(t, e, o) {
                              S = e.type;
                              var n = C(r);
                              "" !== t && "string" == typeof t && t.length <= 255
                                  ? ((n.tp = t),
                                    "string" == typeof e && e.length <= 255
                                        ? ((n.ct = String(e)), k(n, "event", o))
                                        : "object" == (void 0 === e ? "undefined" : s(e))
                                        ? (JSON.stringify(e).length >= 255 &&
                                              console.error("自定义事件参数不能超过255个字符"),
                                          (n.ct = JSON.stringify(e)),
                                          k(n, "event", o))
                                        : void 0 === e || "" === e
                                        ? k(n, "event", o)
                                        : console.error("事件参数必须为String,Object类型,且参数长度不能超过255个字符"))
                                  : console.error("事件名称必须为String类型且不能超过255个字符");
                          },
                          h_OnShareAppMessage: function h_OnShareAppMessage(t) {
                              wx.updateShareMenu({
                                  withShareTicket: !0,
                                  complete: function complete() {
                                      wx.onShareAppMessage(function () {
                                          var e,
                                              o = t(),
                                              n = "",
                                              i = "";
                                          (n = void 0 !== o.success ? o.success : ""),
                                              (i = void 0 !== o.fail ? o.fail : ""),
                                              (e =
                                                  void 0 !== _.query.h_share_src
                                                      ? void 0 !== o.query
                                                          ? (_.query.h_share_src.indexOf(m),
                                                            o.query + "&h_share_src=" + _.query.h_share_src + "," + m)
                                                          : (_.query.h_share_src.indexOf(m),
                                                            "h_share_src=" + _.query.h_share_src + "," + m)
                                                      : void 0 !== o.query
                                                      ? o.query + "&h_share_src=" + m
                                                      : "h_share_src=" + m);
                                          var s = C(r);
                                          return (
                                              (o.query = e),
                                              (s.ct = o),
                                              (s.tp = "h_share_chain"),
                                              k(s, "event"),
                                              (o.success = function (t) {
                                                  (s.tp = "h_share_status"), k(s, "event"), "" !== n && n(t);
                                              }),
                                              (o.fail = function (t) {
                                                  (s.tp = "h_share_fail"), k(s, "event"), "" !== i && i(t);
                                              }),
                                              o
                                          );
                                      });
                                  }
                              });
                          },
                          h_ShareAppMessage: function h_ShareAppMessage(t) {
                              var e,
                                  o = t,
                                  n = "",
                                  i = "";
                              (n = void 0 !== o.success ? o.success : ""),
                                  (i = void 0 !== o.fail ? o.fail : ""),
                                  (e =
                                      void 0 !== _.query.h_share_src
                                          ? void 0 !== o.query
                                              ? (_.query.h_share_src.indexOf(m),
                                                o.query + "&h_share_src=" + _.query.h_share_src + "," + m)
                                              : (_.query.h_share_src.indexOf(m),
                                                "h_share_src=" + _.query.h_share_src + "," + m)
                                          : void 0 !== o.query
                                          ? o.query + "&h_share_src=" + m
                                          : "h_share_src=" + m),
                                  (o.query = e);
                              var s = C(r);
                              (s.ct = o),
                                  (s.tp = "h_share_chain"),
                                  k(s, "event"),
                                  (o.success = function (t) {
                                      (s.tp = "h_share_status"), k(s, "event"), "" !== n && n(t);
                                  }),
                                  (o.fail = function (t) {
                                      (s.tp = "h_share_fail"), k(s, "event"), "" !== i && i(t);
                                  }),
                                  wx.updateShareMenu({
                                      withShareTicket: !0,
                                      complete: function complete() {
                                          wx.shareAppMessage(o);
                                      }
                                  });
                          },
                          h_SendSession: function h_SendSession(t) {
                              if ("" !== t && t) {
                                  var e = C(r);
                                  (e.tp = "session"),
                                      (e.ct = "session"),
                                      (c = t),
                                      "" === h
                                          ? wx.getSetting({
                                                success: function success(t) {
                                                    t.authSetting["scope.userInfo"]
                                                        ? wx.getUserInfo({
                                                              success: function success(t) {
                                                                  (e.ufo = t), k(e, "event");
                                                              }
                                                          })
                                                        : k(e, "event");
                                                }
                                            })
                                          : ((e.ufo = h), "" !== h && (e.gid = ""), k(e, "event"));
                              } else console.error("请传入从后台获取的session_key");
                          },
                          h_SendOpenid: function h_SendOpenid(t) {
                              if ("" !== t && t) {
                                  a = t;
                                  var e = C(r);
                                  (e.tp = "openid"), (e.ct = "openID"), k(e, "event");
                              } else console.error("openID不能为空");
                          },
                          h_ClickAd: function h_ClickAd(t, e) {
                              if (t) {
                                  var o = wx.getStorageSync("tjxx"),
                                      n = Date.now(),
                                      i = 0;
                                  o && "object" === s(o) && 200 === o.Status && (i = o.Result.uid ? o.Result.uid : i),
                                      A().then(function () {
                                          wx.h_SendEvent("clickad", {adv_id: t, timelog: n, type: e}, 1);
                                      });
                              }
                          },
                          h_ToMinProgram: function h_ToMinProgram(t) {
                              var e = t,
                                  o = "",
                                  n = "";
                              function i(t) {
                                  "function" == typeof wx.h_ClickAd &&
                                      e &&
                                      "object" === s(e) &&
                                      e.adv_id &&
                                      wx.h_ClickAd(e.adv_id, t);
                              }
                              (o = void 0 !== e.success ? e.success : ""),
                                  (n = void 0 !== e.fail ? e.fail : ""),
                                  (e.success = function (t) {
                                      i(1), "function" == typeof o && o(t);
                                  }),
                                  (e.fail = function (t) {
                                      i(2), "function" == typeof n && n(t);
                                  }),
                                  wx && wx.navigateToMiniProgram && (i(0), wx.navigateToMiniProgram(e));
                          },
                          h_GetAdv: function h_GetAdv(t) {
                              var e = Date.now(),
                                  o = t && "object" === s(t) ? t : {},
                                  n = o.adv_key ? o.adv_key : "";
                              wx.request({
                                  url: v + "ad/getAdList",
                                  data: {key: n, timelog: e, sign: hex_md5("key:" + n + "timelog:" + e)},
                                  method: "POST",
                                  header: {"content-type": "application/x-www-form-urlencoded", au: i.default.company},
                                  success: function success(t) {
                                      "function" == typeof o.success && o.success(t.data);
                                  },
                                  fail: function fail(t) {
                                      "function" == typeof o.fail && o.fail(t.data);
                                  },
                                  complete: function complete(t) {
                                      "function" == typeof o.complete && o.complete(t.data);
                                  }
                              });
                          },
                          h_GetAdvList: function h_GetAdvList(t) {
                              var e = Date.now(),
                                  o = t && "object" === s(t) ? t : {},
                                  n = o.adv_key ? o.adv_key : "";
                              wx.request({
                                  url: v + "ad/getAdList",
                                  data: {key: n, timelog: e, sign: hex_md5("key:" + n + "timelog:" + e)},
                                  method: "POST",
                                  header: {"content-type": "application/x-www-form-urlencoded", au: i.default.company},
                                  success: function success(t) {
                                      "function" == typeof o.success && o.success(t.data);
                                  },
                                  fail: function fail(t) {
                                      "function" == typeof o.fail && o.fail(t.data);
                                  },
                                  complete: function complete(t) {
                                      "function" == typeof o.complete && o.complete(t.data);
                                  }
                              });
                          },
                          h_GetAdvListPlat: function h_GetAdvListPlat(t) {
                              var e = Date.now(),
                                  o = "object" === s(t) ? t : {},
                                  n = o.adv_key ? o.adv_key : "",
                                  r = 0,
                                  c = wx.getSystemInfoSync();
                              c &&
                                  (-1 !== c.platform.toLowerCase().indexOf("ios")
                                      ? (r = 2)
                                      : -1 !== c.platform.toLowerCase().indexOf("and") && (r = 1)),
                                  wx.request({
                                      url: v + "ad/getAdList",
                                      data: {
                                          key: n,
                                          time: e,
                                          platform: r,
                                          sign: hex_md5("key:" + n + "platform:" + r + "timelog:" + e)
                                      },
                                      method: "POST",
                                      header: {
                                          "content-type": "application/x-www-form-urlencoded",
                                          appid: i.default.app_key,
                                          au: i.default.company
                                      },
                                      success: function success(t) {
                                          "function" == typeof o.success && o.success(t.data);
                                      },
                                      fail: function fail(t) {
                                          "function" == typeof o.fail && o.fail(t.data);
                                      },
                                      complete: function complete(t) {
                                          "function" == typeof o.complete && o.complete(t.data);
                                      }
                                  });
                          },
                          h_GetAppFlowAdList: function h_GetAppFlowAdList(t) {
                              var e = Date.now(),
                                  o = t && "object" === s(t) ? t : {};
                              wx.request({
                                  data: {
                                      appid: i.default.app_key,
                                      timelog: e,
                                      sign: hex_md5("appid:" + i.default.app_key + "timelog:" + e)
                                  },
                                  method: "POST",
                                  header: {"content-type": "application/x-www-form-urlencoded", au: i.default.company},
                                  success: function success(t) {
                                      "function" == typeof o.success && o.success(t.data);
                                  },
                                  fail: function fail(t) {
                                      "function" == typeof o.fail && o.fail(t.data);
                                  },
                                  complete: function complete(t) {
                                      "function" == typeof o.complete && o.complete(t.data);
                                  }
                              });
                          },
                          h_JudgeRegion: function h_JudgeRegion(t) {
                              var e = t && "object" === s(t) ? t : {};
                              wx.request({
                                  url: v + "/ad/scene_area_block",
                                  data: {ak: i.default.app_key},
                                  method: "POST",
                                  header: {"content-type": "application/x-www-form-urlencoded", au: i.default.company},
                                  success: function success(t) {
                                      "function" == typeof e.success && e.success(t.data);
                                  },
                                  fail: function fail(t) {
                                      "function" == typeof e.fail && e.fail(t.data);
                                  },
                                  complete: function complete(t) {
                                      "function" == typeof e.complete && e.complete(t.data);
                                  }
                              });
                          }
                      },
                      R = 0;
                  R < b.length;
                  R++
              ) {
                  !(function (t, e) {
                      Object.defineProperty(wx, t, {value: e, writable: !1, enumerable: !0, configurable: !0});
                  })(b[R], x[b[R]]);
              }
              try {
                  var L = wx.getSystemInfoSync();
                  (r.br = L.brand || ""),
                      (r.md = L.model),
                      (r.pr = L.pixelRatio),
                      (r.sw = L.screenWidth),
                      (r.sh = L.screenHeight),
                      (r.ww = L.windowWidth),
                      (r.wh = L.windowHeight),
                      (r.lang = L.language),
                      (r.wv = L.version),
                      (r.sv = L.system),
                      (r.wvv = L.platform),
                      (r.fs = L.fontSizeSetting),
                      (r.wsdk = L.SDKVersion),
                      (r.bh = L.benchmarkLevel || ""),
                      (r.bt = L.battery || ""),
                      (r.wf = L.wifiSignal || ""),
                      (r.lng = ""),
                      (r.lat = ""),
                      (r.nt = ""),
                      (r.spd = ""),
                      (r.ufo = "");
              } catch (U) {}
          })
        : (r.init = function () {
              console.log("lt sdk not support on windows platform....");
          }),
    (e.exports = o.default);
